import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'



export const counterSlice = createSlice({
    name: 'counter',
    initialState: {
        statr: '北京',
        end: '上海',
        date:dayjs().format('YYYY-MM-DD'),
    },
    reducers: {
        upzhui(state) {
            const timer = state.statr
            state.statr = state.end
            state.end = timer
        },
        // 点击个个城市
        updata(state, action) {
            console.log(action)
            if (action.payload.statr) {
                state.statr = action.payload.city
            } else {
                state.end = action.payload.city
            }
        },


       
    },
})

export const { upzhui, updata } = counterSlice.actions

export default counterSlice.reducer